<?php
/**
 * common model file Created by PhpStorm.
 * User: yang
 * Date: 2020/06/06
 */

namespace Common\Model;

class WebNews extends Base
{
    protected $table = 'web_news';
    protected $guarded = [];

    //public $timestamps = false;

    //一对一关联管理员
    public function get_admin()
    {
        return $this->hasOne(Admin::class, 'id', 'admin_id')
            ->select('id', 'name');
    }

    /**
     * 获取图片可用链接
     * @param $value
     * @return array
     */
    public function getCoverImgAttribute($value)
    {
        $arr_data = [
            'src' => $value,
            'url' => oss_url($value),
        ];
        return $arr_data;
    }

}